#ifndef shm_array_h
#define shm_array_h

#include <stdint.h>

#define MAX_SHMMAT_DIMS 8

#ifdef __cplusplus
extern "C" {
#endif

typedef struct shm_cplxf {
	float real, imag;
} shm_cplxf_t;

typedef struct shm_cplxd {
	double real, imag;
} shm_cplxd_t;

typedef enum shm_array_type {
	shm_array_char,
	shm_array_int32,
	shm_array_int64,
	shm_array_float,
	shm_array_double,
	shm_array_cplxf,
	shm_array_cplxd,

	n_shm_array_types

} shm_array_type_t;


extern int const shm_type_sizes [n_shm_array_types];
extern char const *shm_type_strings [n_shm_array_types];

typedef struct shm_array
{
	shm_array_type_t type;
	int64_t ndims;
	int64_t dims [MAX_SHMMAT_DIMS];
	int64_t region_size;

	union {
		char s[1];
		int i[1];
		float f[1];
		double d[1];
		shm_cplxf_t c[1];
		shm_cplxd_t z[1];
	} data;
} shm_array_t;

int make_shm_array (char const *key, shm_array_t const*, shm_array_t **);

int get_shm_array (char const *key, shm_array_t **);
int put_shm_array (char const *key, shm_array_t *);

int del_shm_array (char const *key);

#ifdef __cplusplus
};
#include "shm_array_type_map.h"
#endif


#endif
